package com.starryx.blog.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration      // 标识配置类
public class WebConfig extends WebMvcConfigurerAdapter {        // 可以重写 web 相关的一些配置

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/admin/**")
                .excludePathPatterns("/admin")          // 排除登录页面的访问
                .excludePathPatterns("/admin/login");   // 排除提交登录信息的访问
    }
}
